
function edit(id){
	var url = 'edit_merchandise_type.html?'+id;
	var config = 'dialogWidth:240px;dialogHeight:70px;scroll:no;status:no;';
	window.showModalDialog(url,'',config);
//	window.open(url,'',config);
	selectMerchandiseType();
};
function selectMerchandiseType(){
	var parent_type_val = escape(escape(document.getElementById('parent_type').value));
	var merchandise_type_name_val = escape(escape(document.getElementById('merchandise_type_name').value));
	
	var url = '/storage/manager/pages/merchandiseType.do?method=selectMerchandiseType&d=' + new Date();
	url = url + '&parent_type_val='+parent_type_val;
	url = url + '&merchandise_type_name_val='+merchandise_type_name_val;
	
	$.getJSON(url, {}, function(data){
		$('#merchandise_type_list').html('');
		
		var _max = get_max_line(470,25);
		for(var i=0;i<data.length;i++){
			var parent_type_val = '';
			for(var k=0;k<parent_type_arr.length;k++){
				if(parent_type_arr[k][0]==data[i][2]){
					parent_type_val = parent_type_arr[k][1];
					break;
				}
			}
			var style_border = 0-(0-i-1)==data.length&&data.length>=_max?'style="border-bottom:0;"':'';
			var merchandiseTypeList = '';
			merchandiseTypeList = merchandiseTypeList + '<tr style="height:25px;" onmouseover="cbgcolor(this,0)" onmouseout="cbgcolor(this,1)">';
			merchandiseTypeList = merchandiseTypeList + '  <td class="list" '+style_border+' width="100" >'+(0-(0-i-1))+'</td>';
			merchandiseTypeList = merchandiseTypeList + '  <td class="list" '+style_border+' width="" >'+parent_type_val+'</td>';
			merchandiseTypeList = merchandiseTypeList + '  <td class="list" '+style_border+' width="300" >'+data[i][1]+'</td>';
			merchandiseTypeList = merchandiseTypeList + '  <td class="list" '+style_border+' width="50" ><a href="javascript:void(0)" onclick="edit('+data[i][0]+')">编辑</a></td>';
			merchandiseTypeList = merchandiseTypeList + '</tr>';
			$('#merchandise_type_list').append(merchandiseTypeList);
		}
		if(data.length<_max){
			add_foot();
		}
	});
};
function add_foot(){
	var foot = '';
    foot = foot + '<tr>';
	foot = foot + '  <td class="list" style="border-bottom:0;" width="100" >&nbsp;</td>';
	foot = foot + '  <td class="list" style="border-bottom:0;" width="" >&nbsp;</td>';
	foot = foot + '  <td class="list" style="border-bottom:0;" width="300" >&nbsp;</td>';
	foot = foot + '  <td class="list" style="border-bottom:0;" width="50" >&nbsp;</td>';
	foot = foot + '</tr>';
	$('#merchandise_type_list').append(foot);
};